<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>User Form</title>
</head>
<body>
<form th:action="@{/user/addUser}" th:object="${user}" method= "post">
    <div>
        <span>用户名：</span>
        <span><input type="text" th:field="*{username}" /></span>
        <span class="warn" th:if="${#fields.hasErrors('username')}" th:errors="*{username}">名字错误</span>
    </div>
    <div>
        <span>年龄：</span>
        <span><input type="text" th:field="*{age}" /></span>
        <span class="warn" th:if="${#fields.hasErrors('age')}" th:errors="*{age}">年龄错误</span>
    </div>
    <div><button type="submit">提交</button></div>
</form>
</body>
</html>